// Copyright  2012 Petr TALLA. [petr.talla@gmail.com]
// This file is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This file is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY;  without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
// [http://www.gnu.org/copyleft/lesser.html]
//=============================================================================

package tc.crase.cmds;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Point2D;

import javax.swing.JLabel;

import tc.common.registry.RegistrySys;
import tc.common.utility.GrView;
import tc.common.utility.TcDisplayTransf;
import tc.crase.sys.XobjectEx;
import tc.crase.view.ViewRoot;

public class CmdEdit extends CmdEx  implements ActionListener {
	
	Point2D.Double xy;
	JLabel selectedLabel;
	
	public CmdEdit () {
		//XdbModel.detail.attrIndex = -1;
	}
	
	public void initializeDialog() {
		super.initializeDialog();
		setLabel("Edit Object");
		setHint("Select object. Next selection opens object editor.");
		
		selectedLabel  = new JLabel("");
		
		dialog.add(selectedLabel);
		
		finalizeDialog();
		
		Selection.objectsAllowed = true;
	}
	
	public void enterSelected(Point pt, GrView view, Object object) {
		RegistrySys.registry.lock(); {
			
			for (int i = 0; i < Selection.selset.size(); i++)
			{	XobjectEx xobji = (XobjectEx)Selection.selset.get(i);
				if (object == (Object)xobji) object = null; //Should not be selected again
				
				ViewRoot.showObject(xobji);
			}
			
			Selection.clean();
			
			if (object instanceof XobjectEx ) {
				Selection.add((XobjectEx)object);
			}

		} RegistrySys.registry.unlock();
	}

	
	public void enterReset(Point pt, GrView view) {
		RegistrySys.registry.lock(); {
			Selection.clean();
		} RegistrySys.registry.unlock();
	}
	
	public void enterMove(Point pt, GrView view) {
	}
	
	private void draw(Graphics g, TcDisplayTransf transf, Color background)	{
	}
	
	public void actionPerformed(ActionEvent e) {
	}
	
}
